<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Book List</title>
<script type="text/javascript" src="JS/jquery-3.2.1.js"></script>
<script type="text/javascript">
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
    }
  }
var url = "Check?thename="+ $("#Name").val();
var encodeUrl = encodeURI(url); 
xmlhttp.open("POST",encodeUrl,true);
xmlhttp.send();
}
</script>
</head>
<body>
<form name="bookFrom" action="AddBook" method="post">
	书名：<input type="text" id ="Name" name="bookName"  onblur="loadXMLDoc()"/><div id="myDiv"></div>
	价格：<input name="price" type="text"/><br/>
	<input type="submit" value="保存" />
</form>
<h6 style="color:red;"><c:out value="${MES}"/></h6>
<c:forEach var="book" items="${Books}" >
	书号：<c:out value="${book.id}" /><br/>
	书名：<c:out value="${book.bookName}" /><br/>
	价格：<c:out value="${book.price}" /><br/>
	<a href="DelBook?id=${book.id}">删除该书</a><br/>
</c:forEach>
<div>
<a href="ShowBook?curPage=1 ">首页</a>
&nbsp
<c:choose>
  <c:when test="${page.curPage==1}"> 
   <a href="ShowBook?curPage=${page.curPage} ">上一页</a>        
  </c:when>
  <c:otherwise>
  <a href="ShowBook?curPage=${page.curPage - 1} ">上一页</a>
  </c:otherwise>
</c:choose>
&nbsp
<c:choose>
  <c:when test="${page.curPage==page.getTotalPages()}"> 
   <a href="ShowBook?curPage=${page.curPage} ">下一页</a>         
  </c:when>
  <c:otherwise>
  <a href="ShowBook?curPage=${page.curPage + 1} ">下一页</a>
  </c:otherwise>
</c:choose>
&nbsp<a href="ShowBook?curPage=${page.getTotalPages()} ">最后一页</a>
</div>
</body>
</html>